package thread;

public class ThreadDemo9_2 {
	public static void main(String args[]) {
		TestThread2 tt = new TestThread2();
		
		Thread th = new Thread(tt, "线程A");
		th.start();
		
		while( Thread.activeCount() > 1 ){
			Thread.yield();
		}
		
		// 循环输出
		for (int i = 0; i < 1000; i++) {
			System.out.println("main 线程在运行" + Thread.currentThread().getName());
		}
	}
}

class TestThread2 implements Runnable {
	@Override
	public void run() {
		for (int i = 0; i < 1000; i++) {
			System.out.println("TestThread 在运行" + Thread.currentThread().getName());
		}
	}
}